package com.badshun.util;

import com.badshun.player.*;

public class BadList<T extends NPCPlayer> {
	private T[] list;
	private int index;
	
	public BadList() {
		list = (T[]) new NPCPlayer[1024];
		index = 0;
	}
	
	public void addChild(T child) {
		list[index] = child;
		index++;
	}
	
	public T getChild(int index) {
		return list[index];
	}
	
	public T removeChild(int index) {
		T child = list[index];
		
		for(int i = 0; i < getLength(); i++) {
			if(i > index) {
				list[i - 1] = list[i]; 
			}
		}
		
		this.index--;
		
		return child;
	}
	
	public int getLength() {
		return index;
	}
}
